var spareId = getQueryString("id");
$(function () {
    $("#jqGrid").Grid({
        url: '../sparepart/getSpconsume',
        colModel: [
            {label: '名称', name: 'name', width: 120},
            {label: '系统编码', name: 'partCode', width: 80},
            {label: '规格', name: 'spec', width: 120},
            {label: '库存数量', name: 'stockNum', index: 'STOCK_NUM', width: 40},
            {label: '出库数量', name: 'outNum', index: 'OUTNUM', width: 40}
            // {label: '报废数量', name: 'num', index: 'NUM', width: 40}
        ]
    });
});
var vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        q: {
            devCode: '', // 备件编码
            spec:'', // 备件规格
            start: '', // 统计开始时间
            end: '', // 统计结束时间
        },
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function (event) {
            vm.showList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            if (this.q.start) {
                this.q.start = gmt2DateStr(this.q.start)
            }
            if (this.q.end) {
                this.q.end = gmt2DateStr(this.q.end)
            }
            $("#jqGrid").jqGrid('setGridParam', {
                postData: this.q,
                page: page
            }).trigger("reloadGrid");
        },
        reloadSearch: function () {
            vm.q = {
                name: '',
                spec:'',
                start: '',
                end: ''
            };
            vm.reload();
        },
        handleSubmit: function (name) {
            handleSubmitValidate(this, name, function () {
                vm.saveOrUpdate()
            });
        }
    }
});
